/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package db;

import java.sql.*;

/**
 *"jdbc:postgres://localhost:1433;" +
                                    "databaseName="+dataBaseName+";" +
                                    "user="+dataBaseUser+";"+
                                    "password="+dataBasePass+";";
 * @author evandro
 */
public class DbConnect {
    private String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
    private static DbConnect dbConnect;
    private Connection con;
    //private String driver = "org.postgresql.Driver";
    //private String dataBaseName = "DB_SQUAD_SAFE";
    private String dataBaseUser = "squadsafe";
    private String dataBasePass = "safe";
    private String urlConnection = "jdbc:sqlserver://OLAVO-NTBOOK\\SQLEXPRESS;databaseName=BD_SQUAD_SAFE";

    private DbConnect(){
        
    }
    public static DbConnect getIntancDbConnect(){
        if(dbConnect == null){
            dbConnect = new DbConnect();
            return dbConnect;
        }
        return dbConnect;
    }
    public void conect(){
        try {
            Class.forName(driver);
            con = DriverManager.getConnection(urlConnection, dataBaseUser, dataBasePass);
        } catch (SQLException e) {
            System.out.println("SQL Exception: "+ e.toString());
        } catch (ClassNotFoundException cE) {
            System.out.println("Classe não encontrada: "+ cE.toString());
        }
         System.out.print("Conexao Realizada");

    }
    public void closeConect(){
        try {
            con.close();
        } catch (SQLException ex) {
           System.err.println("Erro ao tentar fechar o banco de dados\n" + ex);
        }
    }
    public Connection getConect(){
        return con;
    }

}
